﻿using System;
using Jxym.Common.JSON;
using Newtonsoft.Json;
using Jxym.DBUtility;
using Jxym.wlkc2011.Module.Default.model;

namespace Jxym.wlkc2011.Module.Default.SERVER.User
{
    public partial class UserList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    int startIndex = 0, limit = 0, depmetId = 0;
                    if (Request.Params["start"] != null) startIndex = Convert.ToInt32(Request.Params["start"]);
                    if (Request.Params["limit"] != null) limit = Convert.ToInt32(Request.Params["limit"]);
                    if (Request.Params["depmetId"] != null) depmetId = Convert.ToInt32(Request.Params["depmetId"]);

                    if (limit != 0)
                    {
                        string strwhere = "";
                        if (depmetId != 0) { strwhere = "DepartmentID=" + depmetId; }
                        MsSqlDal<User_Info> list = new MsSqlDal<User_Info>();
                        PageBean pb = new PageBean();
                        pb.Count = list.GetPageCount(strwhere, null);
                        pb.List = list.GetPageList(strwhere, null, startIndex, limit);
                        Response.Write(JsonConvert.SerializeObject(pb));
                    }
                    else
                    {
                        Response.Write("{List:[],Count:0}");
                    }
                }
                catch (Exception)
                {
                    Response.Write("{List:[],Count:0}");
                }
            }
        }
    }
}